// pages/calendar/calendar.js
Component({
    /**
     * 页面的初始数据
     */
    data: {
        list:[],
        today:[],
        matter:[],
    },
        ready(){
          this.time()
},
methods:{
    bindTime(e){
        let item = e.currentTarget.dataset.item
        const list=JSON.parse(JSON.stringify( this.data.list))
       list.forEach(e=>{
           e.active=false
        })
        list[item].active=true
        this.getList(list[item].newdata)
        this.setData({
            list,
            today:list[item]
            
        })
    },
    getList(e){
     wx:wx.request({
       url: 'url',
       data: {
        data:e
       },
       url: 'http://127.0.0.1:3007/api//agency/search',
       header: {
         Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInBhc3N3b3JkIjoiIiwiZW1haWwiOiIxNTUwMzE5ODA0QHFxLmNvbSIsInVzZXJfcGljIjpudWxsLCJwaG90byI6bnVsbCwic2V4IjpudWxsLCJiaXJ0aGRheSI6bnVsbCwiYWRkcmVzcyI6bnVsbCwiZGVwYXJ0bWVudCI6bnVsbCwicG9zdCI6bnVsbCwiaWF0IjoxNjY2MDc1OTQ5LCJleHAiOjE2NjYxNjIzNDl9.089VJggCVQspEidtTJk0DhGVI5UE2K0ZLb1gv268jew",
       },
       method: 'POST',
       timeout: 0,
       success: (result) => {
           const list=result.data.data
         
          this.setData({
            matter:list
          })
       },
       fail: (res) => {},
       complete: (res) => {},
     })
    },
    time(e){
        wx.request({
            url: 'http://127.0.0.1:3007/api/agency/GetWeek',
          
            header: {
              Authorization:"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MSwidXNlcm5hbWUiOiJhZG1pbiIsInBhc3N3b3JkIjoiIiwiZW1haWwiOiIxNTUwMzE5ODA0QHFxLmNvbSIsInVzZXJfcGljIjpudWxsLCJwaG90byI6bnVsbCwic2V4IjpudWxsLCJiaXJ0aGRheSI6bnVsbCwiYWRkcmVzcyI6bnVsbCwiZGVwYXJ0bWVudCI6bnVsbCwicG9zdCI6bnVsbCwiaWF0IjoxNjY2MDc2MjIzLCJleHAiOjE2NjYxNjI2MjN9.8F6yme5O0bcprCPKQTYavskEqNT_cimTXu-WDy0GB4M",
            },
            method: 'GET',
            timeout: 0,
            success: (result) => {
                console.log(result.data);
              const week = result.data.data[0]
              week.active=true
              this.getList(week.newdata)
                this.setData({
                       list:result.data.data,
                        today:week
                       })
            },
            fail: (res) => {},
            complete: (res) => {},
          })
    }
},
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {
       
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})